package cn.iocoder.yudao.module.brokerage.framework;

import cn.iocoder.yudao.framework.datapermission.v1.UniDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.brokerage.merchant.pojo.po.AgencyBrokerageRecordDO;
import cn.iocoder.yudao.module.brokerage.merchant.pojo.po.AgencyMerchantDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * permission 组件的配置类
 */
@Configuration(proxyBeanMethods = false, value = "brokeragePermissionConfiguration")
public class DataPermissionConfiguration {

    @Bean
    public UniDataPermissionRuleCustomizer brokerageDataPermissionRuleCustomizer() {
        return rule -> {
            // shop 基于店铺的数据权限
            rule.addDataColumn(AgencyMerchantDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(AgencyBrokerageRecordDO.class, "source_shop_id", "shop_id"); // WHERE source_shop_id = ?
        };
    }

}
